package com.easyaccount.commons;

public class CommonResp<T> {

    private String msg;
    private int code;
    private T data;

    public static CommonResp success(){
        CommonResp commonResp = new CommonResp();
        commonResp.setCode(200);
        return commonResp;
    }

    public static CommonResp success(String msg){
        CommonResp commonResp = success();
        commonResp.setMsg(msg);
        return commonResp;
    }

    public static <T> CommonResp success(T data){
        CommonResp commonResp = success();
        commonResp.setData(data);
        return commonResp;
    }

    public static CommonResp failed(String msg,int code){
        CommonResp commonResp = new CommonResp();
        commonResp.setCode(code);
        commonResp.setMsg(msg);
        return commonResp;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
